/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package main.Weighting;

import java.io.Serializable;
import java.util.regex.Pattern;
import main.NER.Trie.NER_Candidate;

/**
 *
 * @author Isaac Osesina
 */
public class DispersionWeightingFunction  extends AbstractWeightingFunction implements WeightingMethod, Serializable{

    public DispersionWeightingFunction() {
    }

    @Override
	public WeightingScore getEvaluateScore(NER_Candidate candidate, double intrinsicThreshold, double lCxtThreshold, double rCxtThreshold) {
        double lCxtProb = getContextProbability(candidate, true, lCxtThreshold);
        double rCxtProb = getContextProbability(candidate, false, rCxtThreshold);
        double contextualProb = lCxtProb * rCxtProb;
        Pattern entityClassRegex = candidate.getEntityClassRegex();
        double intrinsicProbability = getIntrinsicProbability(candidate.getEntityValue(), entityClassRegex, intrinsicThreshold);
        double dispersionProb = lCxtProb * rCxtProb * intrinsicProbability;
        WeightingScore weightingScore = new WeightingScore(contextualProb, lCxtProb, rCxtProb, intrinsicProbability, dispersionProb, this.getClass().getName());
        weightingScore.setThreshold(intrinsicThreshold, lCxtThreshold, rCxtThreshold);
        return weightingScore;
    }
    
}
